let fs = require('fs');
let buf = '';

process.stdin.on('readable', function() {
    let chunk = process.stdin.read();
    if (chunk) buf += chunk.toString();
});

let gcd = (a, b) => {
    let c = 0;
    while (b !== 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

process.stdin.on('end', function() {
    let input = buf.split("\n")[0];
    let [a, b] = input.split(" ").map((x)=>{return parseInt(x);});
    let ret = gcd(a, b);
    console.log(ret);
});